import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import ParentView from '@/components/ParentView';

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    noCache: true                // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

// 公共路由
export const constantRoutes = [{
		path: '/redirect',
		component: Layout,
		hidden: true,
		children: [{
			path: '/redirect/:path(.*)',
			component: (resolve) => require(['@/views/redirect'], resolve)
		}]
	},
	{
		path: '/login',
		component: (resolve) => require(['@/views/login'], resolve),
		hidden: true
	},
	{
		path: '/404',
		component: (resolve) => require(['@/views/error/404'], resolve),
		hidden: true
	},
	{
		path: '/401',
		component: (resolve) => require(['@/views/error/401'], resolve),
		hidden: true
	},

	{
		path: '',
		component: Layout,
		redirect: 'index',
		meta: {
			title: '系统首页',
			icon: 'dashboard'
		},
		children: [{
			path: 'index',
			component: (resolve) => require(['@/views/index_v1'], resolve),
			name: '系统首页',
			meta: {
				title: '系统首页',
				icon: 'dashboard',
				noCache: true,
				//affix: true
			}
		}]
	},
	{
		path: '/info',
		component: Layout,
		name: "基础数据",
		alwaysShow: true,
		meta: {
			title: '基础数据',
			permission: '5000',
			icon: 'table'
		},
		children: [{
				path: 'pro',
				component: (resolve) => require(['@/views/control/pro/index.vue'], resolve),
				name: 'pro',
				meta: {
					title: '生产单位管理',
					icon: 'edit',
					noCache: true,
					//affix: true
				}
			},
			{
				path: 'transport',
				component: (resolve) => require(['@/views/control/transport/index.vue'], resolve),
				name: 'transport',
				meta: {
					title: '收运单位管理',
					icon: 'edit',
					noCache: true,
					//affix: true
				}
			},
			{
				path: 'car',
				component: (resolve) => require(['@/views/control/car/index.vue'], resolve),
				name: 'car',
				meta: {
					title: '收运车辆管理',
					icon: 'edit',
					noCache: true,
					//affix: true
				}
			},
			{
				path: 'driver',
				component: (resolve) => require(['@/views/control/driver/index.vue'], resolve),
				name: 'driver',
				meta: {
					title: '驾驶员管理',
					icon: 'edit',
					noCache: true,
					//affix: true
				}
			},
			{
				path: 'box',
				component: (resolve) => require(['@/views/control/box/index.vue'], resolve),
				name: 'box',
				meta: {
					title: '专用桶管理',
					icon: 'edit',
					noCache: true,
					//affix: true
				}
			}
		]
	},
	{
		path: '/jg',
		component: Layout,
		name: "产生监管",
		alwaysShow: true,
		meta: {
			title: '产生监管',
			permission: '5000',
			icon: 'international'
		},
		children: [{
				path: 'zj',
				component: (resolve) => require(['@/views/control/zj/index.vue'], resolve),
				name: 'zj',
				meta: {
					title: '收集量在线采集',
					icon: 'form',
					noCache: true,
					//affix: true
				}
			},
			{
				path: 'gis',
				component: (resolve) => require(['@/views/control/gis/index.vue'], resolve),
				name: 'gis',
				meta: {
					title: '产生点GIS展示',
					icon: 'guide',
					noCache: true,
					//affix: true
				}
			}
		]
	},
	{
		path: '/syjg',
		component: Layout,
		name: "收运监管",
		alwaysShow: true,
		meta: {
			title: '收运监管',
			permission: '5000',
			icon: 'example'
		},
		children: [{
				path: 'plant',
				component: (resolve) => require(['@/views/control/plant/index.vue'], resolve),
				name: 'plant',
				meta: {
					title: '收运计划管理',
					icon: 'edit',
					noCache: true,
					//affix: true
				}
			},
			{
				path: 'mapscar',
				component: (resolve) => require(['@/views/control/gis/mapscar.vue'], resolve),
				name: 'mapscar',
				meta: {
					title: '实时位置',
					icon: 'international',
					noCache: true,
					//affix: true
				}
			},
			{
				path: 'gg',
				component: (resolve) => require(['@/views/control/map/maps.vue'], resolve),
				name: 'gg',
				meta: {
					title: '作业轨迹',
					icon: 'guide',
					noCache: false,
					//affix: true
				}
			},
			{
				path: 'label',
				component: (resolve) => require(['@/views/control/label/index.vue'], resolve),
				name: 'label',
				meta: {
					title: '收运记录',
					icon: 'form',
					noCache: true,
					//affix: true
				}
			},
			{
				path: 'dchart',
				component: (resolve) => require(['@/views/control/batinfo/dchart.vue'], resolve),
				name: 'dchart',
				meta: {
					title: '车辆运行统计',
					icon: 'chart',
					noCache: true,
					//affix: true
				}
			}
		]
	},
	{
		path: '/user',
		component: Layout,
		hidden: true,
		redirect: 'noredirect',

		children: [{
			path: 'profile',
			component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
			name: 'Profile',
			meta: {
				title: '个人中心',
				icon: 'user'
			}
		}]
	},
	{
		path: '/sys',
		component: Layout,
		name: "系统管理",
		alwaysShow: true,
		meta: {
			title: '系统管理',
			permission: '5000',
			icon: 'theme'
		},
		children: [{
				path: 'age',
				component: () => import('@/views/control/user/userlist.vue'),
				name: 'user',
				hidden: false,
				meta: {
					title: '用户设置',
					permission: '5100',
					icon: 'peoples'
				}
			},
			{
				path: 'capacity',
				component: () => import('@/views/control/user/role.vue'),
				name: 'role',
				hidden: false,
				meta: {
					title: '权限设置',
					permission: '5200',
					icon: 'lock'
				}
			},

			{
				path: 'department',
				component: () => import('@/views/control/department/index.vue'),
				name: '部门管理',
				hidden: false,
				meta: {
					title: '部门管理',
					permission: '5300',
					icon: 'tree'
				}
			}
		]
	}, {
		path: '*', // 此处需特别注意至于最底部
		redirect: '/404'
	}
]

export default new Router({
	base: "/",
	mode: 'history', // 去掉url中的#
	//mode:'hash',
	scrollBehavior: () => ({
		y: 0
	}),
	routes: constantRoutes
})
